package com.qiang;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Test11 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        list.add("林青霞");
        list.add("张曼玉");
        list.add("王祖贤");
        list.add("柳岩");
        list.add("张敏");
        list.add("张无忌");
        List<String> zhang = list.stream().filter(s -> s.startsWith("张")).filter(s -> s.length() == 3).collect(Collectors.toList());
        for (int i = 0; i < zhang.size(); i++) {
            System.out.println(zhang.get(i));
        }
        list.stream().filter(s -> s.startsWith("张")).filter(s -> s.length() == 3).forEach(s-> System.out.println(s));
        long count = list.stream().filter(s -> s.startsWith("张")).filter(s -> s.length() == 3).count();
        System.out.println(count);
    }
}
